package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/*有参方法*/
public class reflectDemo5 {
    public static void main(String[] args) throws Exception{
        Class<?> aClass = Class.forName("reflect.Person");
        Constructor<?> constructor = aClass.getConstructor(String.class);
//        Object o = aClass.newInstance("张茜");
        Object o = constructor.newInstance("张强");
        Method method1 = aClass.getMethod("seeHello3", String.class);
        method1.invoke(o,"哈哈");

        Method method2 = aClass.getMethod("seeHello3", String.class, int.class);
        method2.invoke(o, "嘿嘿", 5);

        


    }
}
